# Maintainer: Taner Tas <taner76@gmail.com>
pkgname=advancemame
pkgver=3.9
pkgrel=4
pkgdesc="A port of the MAME emulator for Arcade Monitors and TVs but also for LCDs and PC monitors"
url="http://www.advancemame.it"
# armhf: fails with clang
arch="all !armhf"
license="GPL-2.0-only"
makedepends="
	alsa-lib-dev
	clang
	expat-dev
	freetype-dev
	linux-headers
	sdl2-dev
	slang-dev
	zlib-dev
	"
subpackages="$pkgname-doc $pkgname-data::noarch $pkgname-mess $pkgname-menu"
source="https://github.com/amadvance/advancemame/releases/download/v$pkgver/advancemame-$pkgver.tar.gz
	fix-ppc64le-float128.patch
	formatsec.patch
	"
options="!check"

# Fix build with gcc 10
export CFLAGS="$CFLAGS -fcommon"

prepare() {
	default_prepare

	update_config_guess
	update_config_sub
}

build() {
	export CC=clang
	export CXX=clang++

	./configure \
		--build=$CBUILD \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-fb \
		--enable-sdl2
	make
}

package() {
	make bindir="$pkgdir/usr/bin/" \
	datadir="$pkgdir/usr/share/" \
	mandir="$pkgdir/usr/share/man/" \
	pkgdocdir="$pkgdir/usr/share/doc/$pkgname/" \
	install
}

data() {
	pkgdesc="Distribution files for advancemame"
	depends="$pkgname=$pkgver-r$pkgrel"
	amove usr/share/advance/*
}

mess() {
	pkgdesc="Advancemame port of MESS."
	amove usr/bin/advmess

}

menu() {
	pkgdesc="An emulator frontend with sound and animated previews of your games."
	amove usr/bin/advmenu

}
sha512sums="
43f9ba746f222b17ade2d213d6af7cc8fe6b3ee6008633f02b8877f4c7f75628bdf1cc9718db09f5f9a482d194c8ba94f9047334e8012d23c598454e5dab2eb3  advancemame-3.9.tar.gz
d42a9b3c65c2d96be5287c7541eb1e911562b3f2aaf07c55c1849725592857716ce496405e3da2243edcbd4b7307226306533ddf66ef2e081b4c492412930d1b  fix-ppc64le-float128.patch
461a76d3db95d9c894ec6937be18f2d1d7f193c2c06e14c4b3bb7cb860c7b2054f46fac636c8ebd9616d48a079b07f6cd2b1647ec0d706e26a473ac08d1ce504  formatsec.patch
"
